package com.codejoys.monitor.dao;

import com.codejoys.monitor.domain.Device;
import com.codejoys.monitor.domain.DeviceData;
import com.codejoys.monitor.domain.VoltageModeConfig;
import com.codejoys.monitor.dto.DeviceDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface DeviceDao {
    List<DeviceDto> findList(
            @Param("device")DeviceDto device,
            @Param("start") Integer start,
            @Param("limit") Integer limit);

    List<DeviceDto> statusDeviceList(String house);
    List<DeviceData> statusDataList(List<Integer> ids);

     /**
     * 获得每个老化房绑定的设备的状态，通道号，设备号
     * @param house
     * @return
     */
    List<DeviceDto> getDeviceStatus(String house);


    int countList(DeviceDto device);

    void batchInsert(List<DeviceDto> devices);

    int updateDeviceAgingStartTime(
            @Param("channel") String channel,
            @Param("time") Date time
    );

    Device selectNewAddedDeviceAtChannel(String channel);

    // 查询通道上最近添加的一个设备
    Device selectLatestDeviceAtChannel(String channel);

    List<DeviceDto> selectAgingDevices();
    
    List<DeviceDto> selectExpiredDevices();

    VoltageModeConfig findVoltageModeConfig(
            @Param("model") String model,
            @Param("channelId") Integer channelId);

    void batchDetach(
            @Param("ids") List<Integer> ids,
            @Param("offlineTime") Date offlineTime);

    List<DeviceData> findLastDataItems(
            List<Integer> ids,
            @Param("limit") int limit);

    List<DeviceDto> channelsStatusList(String[] channels);

    List<DeviceDto> findExportList(DeviceDto device);
}
